// date-time-utils.js

// 获取当前年月日时分秒的函数
export function getTime() {
    const currentDateTime = new Date();
    const year = currentDateTime.getFullYear();
    const month = addZeroIfNeeded(currentDateTime.getMonth() + 1);
    const day = addZeroIfNeeded(currentDateTime.getDate());
    const hours = addZeroIfNeeded(currentDateTime.getHours());
    const minutes = addZeroIfNeeded(currentDateTime.getMinutes());
    const seconds = addZeroIfNeeded(currentDateTime.getSeconds());
  
    return {
      year,
      month,
      day,
      hours,
      minutes,
      seconds,
      formattedDateTime: `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`,
    };
  }
  
  // 在数字前添加0的辅助函数
  function addZeroIfNeeded(value) {
    return value < 10 ? '0' + value : value;
  }
  